#!/bin/bash

# 打印颜色文本
print_color() {
  case $1 in
    "green") COLOR='\033[0;32m' ;;
    "red") COLOR='\033[0;31m' ;;
    "blue") COLOR='\033[0;34m' ;;
    *) COLOR='\033[0m' ;;
  esac
  NC='\033[0m' # No Color
  echo -e "${COLOR}$2${NC}"
}

# 安装依赖
print_color "blue" "=== 正在安装依赖... ==="
npm install

# 检查安装结果
if [ $? -eq 0 ]; then
  print_color "green" "=== 依赖安装成功! ==="
  
  # 启动开发服务器
  print_color "blue" "=== 正在启动开发服务器... ==="
  npm run dev
else
  print_color "red" "=== 依赖安装失败，请检查错误信息 ==="
  exit 1
fi 